package edu.chinasoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;


/**
 * Servlet implementation class Servlet01
 */
@WebServlet(name="myServlet01",value="/servlet/Servlet01")
public class Servlet01 extends HttpServlet {
	private static Logger logger = Logger.getLogger(Servlet01.class);       
    
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		logger.debug("Servlet01>>>doGet  start……");
		//设置响应对象   以字符为单位的乱码问题
		response.setContentType("text/html;charset=utf-8");
		//设置post请求的乱码问题
		request.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		logger.debug("Servlet01>>>doGet  end……");
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		logger.debug("Servlet01>>>doPost  start……");
		request.setCharacterEncoding("UTF-8");
		String content=request.getParameter("content");
		logger.debug("获取到的内容为："+content+"。");
		logger.debug("Servlet01>>>doPost  end……");
	}

}
